
import com.jme3.input.controls.KeyTrigger;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import de.stoneageracer.core.RacingApplication;
import de.stoneageracer.vehicles.Car;

/**
 *
 * @author Basti
 */
public class MenuTest extends RacingApplication{
        
    /**
     * Overrides simpleInit Method of RacingApplication
     * Put all your Menu-Initialising Code here!
     */
    @Override
    public void simpleInitApp(){
        super.simpleInitApp();
        initPhysics();
        initWorld("Scenes/scene.obj", "Scenes/scene.obj");
        initSky("Textures/himmel.jpg");
        initPostProcessing();
        Car car = new Car("Models/Ferrari/Car.scene");
        buildPlayer(car,-40,5,-70).setPhysicsRotation(new Quaternion(0, FastMath.PI, 0, 0));
        flyCam.setEnabled(false);
        cam.setLocation(new Vector3f(16.650297f, -11.565172f, 5.7418084f));
        cam.setDirection(new Vector3f(-0.83574337f, -0.18665203f, -0.5164244f));
        addGuiText("SinglePlayer\nMultiPlayer\nOptions\nEnd", new Vector3f(10, 100, 0)).setColor(new ColorRGBA(1,1,1,1));
        
        inputManager.addMapping("SinglePlayer", new KeyTrigger(keyInput.KEY_SPACE));
        inputManager.addListener(this, "SinglePlayer");
    }
    
    /**
     * Main method to start the Game
     * @param args
     */
    public static void main(String[] args){
        new MenuTest().start();
    }

    /**
     * Key-Checks here (for now only loads a map when you press "SPACE"
     * @param name name of the Action
     * @param isPressed boolean whether a key is pressed
     * @param tpf "Time Per Frame"
     */
    @Override
    public void onAction(String name, boolean isPressed, float tpf) {
        super.onAction(name, isPressed, tpf);
        if(name.equals("SinglePlayer")&&isPressed){
            inputManager.removeListener(this);
            reset();
            simpleInitGame();
        }
    }
    
    /**
     * Initialises a "Level"
     * Copy and rewrite this method for each level (dont forget to reset(); before you call this method
     */
    public void simpleInitGame(){
        System.out.println("Started GameTest");
        initPhysics();
        initWorld("Scenes/scene.obj", "Scenes/scene.obj");
        initSky("Textures/himmel.jpg");
        Car car = new Car("Models/Ferrari/Car.scene");
        car.addTo(rootNode,0,0,0,this);
        //carN.attachChild(createEmitter(new Vector3f(0,0,3),new ColorRGBA(0f, 0f, 0f, 1f),new ColorRGBA(1f, 1f, 1f, .4f)));//ParticleTest
        //buildPlayer(car,0,0,10);//SecondCar (Physics-)Test
        initCam(car.node);
        initKeys();
        initPostProcessing();
        initKMH("Speed: ","kmh",new Vector3f(300, 40, 0));
        
    }
}
